/**
 * Created with IntelliJ IDEA
 * Description:
 * User: SEKI TOMOKI
 * Date: 2023-09-28
 * Time: 20:32
 */
import java.util.*;

class Solution {
    public List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> ret = new ArrayList<>();

        while(left <= right) {
            boolean flg = false;

            int tmp = left;
            //加上 tmp % 10 != 0 是为了防止自除数出现0的情况
            while(tmp != 0 && tmp % 10 != 0) {
                if(left % (tmp%10) != 0) {
                    break;
                }
                tmp = tmp / 10;
            }

            if(tmp == 0) {
                flg = true;
            }

            if(flg) {
                ret.add(left);
            }
            left++;
        }
        return ret;
    }
}
